package 算法.排序;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.PriorityQueue;

public class test {
    public static void main(String[] args) {
        PriorityQueue<Integer> max = new PriorityQueue<>();
        PriorityQueue<Integer> min = new PriorityQueue<>((o1, o2)->o2.compareTo(o1));
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            Integer next = iterator.next();
            max.offer(next);
            min.offer(next);
        }
        System.out.println("====小顶堆==========");
        System.out.println(max.poll());
        System.out.println("====大顶堆==========");
        System.out.println(min.poll());
    }
}
